﻿<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Page Language="C#" Inherits="Codeplex.SPCleanup.ApplicationPages.ListCleanupSettingsPage, Codeplex.SPCleanup.ApplicationPages, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=36ab4294bd41212b" MasterPageFile="~/_layouts/application.master" EnableViewState="false" EnableViewStateMac="false"   %> 
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="LinkSection" src="~/_controltemplates/LinkSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>

<asp:Content ID="Content1" contentplaceholderid="PlaceHolderPageTitle" runat="server">
	<SharePoint:FormattedStringWithListType ID="lblTitle" runat="server"
		String="{0} CleanUp Settings" LowerCase="false" />
</asp:Content>
<asp:Content ID="Content2" contentplaceholderid="PlaceHolderPageTitleInTitleArea" runat="server">
	<SharePoint:FormattedStringWithListType ID="lblTitleInTitleArea" runat="server"
		String="{0} CleanUp Settings:" LowerCase="false" />
	<a id=onetidListHlink HREF=<% SPHttpUtility.AddQuote(SPHttpUtility.UrlPathEncode(List.DefaultViewUrl,true),Response.Output);%>><%SPHttpUtility.HtmlEncode(List.Title,Response.Output);%></a>
</asp:Content>

<asp:Content ID="Content3" contentplaceholderid="PlaceHolderPageDescription" runat="server"></asp:Content>

<asp:Content ID="Content4" contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
<script language="javascript">
    function EnableDisableControls(ChkState)
    {        
        var ChkBrowseSubfolders = document.getElementById('<%= ChkBrowseSubfolders.ClientID %>');
        var ChkDeleteSubfolders = document.getElementById('<%= ChkDeleteSubfolders.ClientID %>');
        var ChkSendNotification = document.getElementById('<%= ChkSendNotification.ClientID %>');
    
        document.getElementById('<%= TxtTimeSpan.ClientID %>').disabled=!ChkState;                               
        if (null != ChkBrowseSubfolders && undefined != ChkBrowseSubfolders)
        {
            ChkBrowseSubfolders.disabled=!ChkState;                       
        }
        
        if (null != ChkDeleteSubfolders && undefined != ChkDeleteSubfolders)
        {
            if (ChkState)
            {
                  ChkDeleteSubfolders.disabled = !ChkBrowseSubfolders.checked;                
            }
            else
            {
                  ChkDeleteSubfolders.disabled = !ChkState;                
            }
        }
                
        if (null != ChkSendNotification && undefined != ChkSendNotification)
        {
            ChkSendNotification.disabled=!ChkState;
        }                      
    }
    
    
    function EnableDisableDeleteFolderOption(ChkState)
    {
        document.getElementById('<%= ChkDeleteSubfolders.ClientID %>').disabled=!ChkState;
    }
    
    function _spBodyOnLoadWrapper()
    {        
        EnableDisableControls(document.getElementById('<%= ChkEnableCleanUp.ClientID %>').checked);
    }
    
    function EnableControls()
    {
        var ChkBrowseSubfolders = document.getElementById('<%= ChkBrowseSubfolders.ClientID %>');
        var ChkDeleteSubfolders = document.getElementById('<%= ChkDeleteSubfolders.ClientID %>');
        var ChkSendNotification = document.getElementById('<%= ChkSendNotification.ClientID %>');
        
        document.getElementById('<%= TxtTimeSpan.ClientID %>').disabled = false;
        
        if (null != ChkBrowseSubfolders && undefined != ChkBrowseSubfolders)
        {
            ChkBrowseSubfolders.disabled=false;           
        }
        if (null != ChkDeleteSubfolders && undefined != ChkDeleteSubfolders)
        {
            ChkDeleteSubfolders.disabled = false;
        }
        
        if (null != ChkSendNotification && undefined != ChkSendNotification)
        {
            ChkSendNotification.disabled = false;
        }          
    }
    
</script>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table border="0" width="100%" cellspacing="0" cellpadding="0" class="ms-descriptiontext">
       <wssuc:InputFormSection runat="server" Title="Enable Cleanup">
	        <Template_Description>
	            <SharePoint:FormattedStringWithListType ID="lblEnableCleanupDesc" runat="server" String="Enabling cleanup for this {0} will run the cleanup job every day to delete the old items." />
	        </Template_Description>   
	        
	        <Template_InputFormControls>    		                 	                
	             <wssawc:InputFormCheckBox LabelText="Enable cleanup" runat="server" ID="ChkEnableCleanUp"></wssawc:InputFormCheckBox> 	                
	        </Template_InputFormControls>	             
	    </wssuc:InputFormSection>
	    
	     <wssuc:InputFormSection runat="server" Title="Time Span (hours)">
	         <Template_Description>
	                <SharePoint:EncodedLiteral ID="lblTimeSpanDesc" runat="server" text="Items that has not been modified for more than these hours will be deleted. -1 for infinite time." EncodeMethod="HtmlEncodeAllowSimpleTextFormatting"/>
	                Blank is treated as <span style="color:red"><b>-1</b></span>.
	         </Template_Description>
	         <Template_InputFormControls>
	            <wssuc:InputFormControl LabelText="Time span" runat="server">
	                <Template_Control>
	                    <wssawc:InputFormTextBox Title="Time Span" class="ms-input" ID="TxtTimeSpan" Columns="35" runat="server" MaxLength="6" />
	                    <wssawc:InputFormCustomValidator runat="server" ControlToValidate="TxtTimeSpan" OnServerValidate="ListCleanUp_CustomValidator" EnableClientScript="false" ErrorMessage="Enter a valid input for time span"></wssawc:InputFormCustomValidator>
	                </Template_Control>
	            </wssuc:InputFormControl>
	         </Template_InputFormControls>	         
	     </wssuc:InputFormSection>
	     
	     <asp:Panel ID="pnlDocLibOptions" runat="server" Visible="false">
	      
	          <wssuc:InputFormSection runat="server" Title="Subfolders">
	            <Template_Description>
	                <SharePoint:EncodedLiteral ID="lblScanSubfoldersDesc" runat="server" EncodeMethod='HtmlEncode' text="Enabling scan subfolder option will recursively scan the subfolders for the clean up. Delete subfolder option will delete the subfolder itself if all the items in that subfolder are deleted and it is empty." />
	            </Template_Description>   
    	        
	            <Template_InputFormControls>    		                 	                
	                 <wssawc:InputFormCheckBox LabelText="Scan subfolders" runat="server" ID="ChkBrowseSubfolders"></wssawc:InputFormCheckBox> 	                
	                 <wssawc:InputFormCheckBox LabelText="Delete subfolders" runat="server" ID="ChkDeleteSubfolders"></wssawc:InputFormCheckBox> 	                
	            </Template_InputFormControls>	             
	        </wssuc:InputFormSection>	   	    
	    
	    <wssuc:InputFormSection runat="server" Title="Send Email">
	        <Template_Description>
	            <SharePoint:EncodedLiteral ID="lblEmailOwnerDesc" runat="server" EncodeMethod='HtmlEncode' text="Enabling email option will send notification to the item owner after it has been deleted. Outgoing email settings has to be configured in the farm to send notifications." />
	        </Template_Description>   
	        
	        <Template_InputFormControls>    		                 	                
	             <wssawc:InputFormCheckBox LabelText="Send email" runat="server" ID="ChkSendNotification"></wssawc:InputFormCheckBox> 	                
	        </Template_InputFormControls>	             
	    </wssuc:InputFormSection>
	    
	    </asp:Panel>
	    
	    <wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
	        <Template_Buttons>
		        <asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" OnClick="BtnSave_Click" Text="Save" id="BtnSave" accesskey="S"/>
		        <input class="ms-ButtonHeightWidth" type="button" name="BtnCancel" id="BtnCancel" value="Cancel" accesskey="C" runat="server" />                
	        </Template_Buttons>
        </wssuc:ButtonSection>	    	   	   	    	   	 
	    
    </table>
</asp:Content>
